<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class AdminComment extends Model
{
    use HasFactory;
    protected $table = 'admin_article_comment';
    public function userInfo(){
        return $this->hasOne(AdminUser::class,'id','uid');
    }
    public function comment($data,$pid=0){
        $child = [];
        foreach ($data as $k=>$v){
            if($v['pid']==$pid){
                $child[] = $v;
            }
        }
        foreach ($child as $kk=>$vv){
            $child[$kk]['child'] = self::comment($data,$vv['id']);
        }
        return $child;
    }
}
